package com.itlong.cloud.POJO.VO.property;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <desc>
 *      访客信息VO
 * </desc>
 *
 * @createDate 2018/06/29
 */

@Data
@NoArgsConstructor
public class PropertyGetVisitorInfoVO {

    private String intervieweeName;         //受访人姓名
    private String visitorName;             //访客姓名
    private String visitorPhone;            //访客手机
    private String visitorIdCard;           //访客身份证号
    private String passId;                  //访客Id
    private String address;                 //使用地址
    private String buildId;                 //楼栋Id
    private String unitId;                  //单元Id
    private String floorNum;                //楼层
    private String visitorCause;            //访客事由
    private String password;                //动态密码
    private String qrcodeUrl;               //二维码url
    private String roomId;                  //房间ID
    private String roomNum;                  //房间编号
    private Integer source;                 //数据来源 1APP 2物业
    private Integer visitorQrCodeUsableTimes;
    private double effectiveTime;             //有效时间

    private String startTime;                 //有效起始时间
    private String endTime;                   //有效结束时间

    private Integer ownerCheckStatus;         //业主审批状态
    private String facePicUrl;                //人脸头像地址
    private String vFaceId;                   //人脸编号
    private String idcardKey;               //身份证序号
    private String projectId;               //项目编号
    private String deviceUniques;           //临时权限设备唯一码集合,多个以逗号隔开
    private Integer temporaryAuthType;      //临时权限设备类型 0全部 1部分设备
    private String createTime;              //创建时间
    private String operator;                //操作人
    private String isExpired;               //是否过期 1未过期 2已过期
    private String passNumber;              //访客单号
    private Integer checkStatus;            //物业审核状态 0代表未审批 1代表审批通过 2代表审批拒绝
    private String checkOperator = "系统";           //物业审批人员
    private String checkTime;               //物业审批时间
    private String qrcode;                  //二维码生成信息
    public double getEffectiveTime(){
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );

        long nd = 1000 * 24 * 60 * 60;
        long nh = 1000 * 60;
        if(startTime==null || endTime == null){
            return 0;
        }else{
            try {
                long diff = df.parse(endTime).getTime()-df.parse(startTime).getTime();
                /*if(diff==1800000){
                    return 0.5;
                }*/
                long hour = diff/nh;
                if(hour ==1439){
                    hour=1440;
                }
                return hour;
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return 0;
        }
    }

}